package com.zttek.videoShareProject.modules.web;


import com.zttek.videoShareProject.common.base.MyBaseController;
import com.zttek.videoShareProject.common.json.FollowVO;
import com.zttek.videoShareProject.modules.model.Follow;
import com.zttek.videoShareProject.modules.service.IFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author CBY
 * @since 2018-07-03
 */
@Controller
@RequestMapping("/follow")
public class FollowController extends MyBaseController{
    @Autowired
    private IFollowService followService;


    @ResponseBody
    @RequestMapping(value = "deal_follow",method = RequestMethod.POST)
    public Object dealFollw(@RequestBody FollowVO.FollowForm followForm){
        try {
            if(followForm.getIs_follow()==0){//添加关注
                followService.insertFollow(followForm.getFollow());
            }else{//取消关注
                followService.deleteFollw(followForm.getFollow());
            }
        } catch (Exception e) {
            e.printStackTrace();
            return renderError();
        }
        return renderSuccess();
    }
	
}
